package com.ashapo.example;

public class Example018Abstract {

    /**
     * 测试抽象类
     * @param args
     */
    public static void main(String[] args) {
        Honda4.runMain();

        TestBank.run();
    }
}

abstract class Bike {
    abstract void run();
}

class Honda4 extends Bike {
    void run() {// run 方法的实现
        System.out.println("running safely..");
    }

    public static void runMain() {
        Bike obj = new Honda4();
        obj.run();
    }
}


abstract class Bank2 {
    abstract int getRateOfInterest();
}

class SBI2 extends Bank2 {
    int getRateOfInterest() {
        return 7;
    }
}

class PNB2 extends Bank2 {
    int getRateOfInterest() {
        return 8;
    }
}

class TestBank {
    public static void run() {
        Bank2 b;
        b = new SBI2();
        System.out.println("Rate of Interest is: " + b.getRateOfInterest() + " %");
        b = new PNB2();
        System.out.println("Rate of Interest is: " + b.getRateOfInterest() + " %");
    }
}